home *** CD-ROM | disk | FTP | other *** search
/ Celestin Apprentice 5 / Apprentice-Release5.iso / Environments / SmallEiffel 0.3.3 / SmallEiffel PPC / lib_show / parking / run_parking.e < prev    next >
Encoding:
Text File  |  1996-06-13  |  2.3 KB  |  96 lines  |  [TEXT/EDIT]

  1. -- Part of SmallEiffel -- Read DISCLAIMER file -- Copyright (C) 
  2. -- Dominique COLNET and Suzanne COLLIN -- colnet@loria.fr
  3. --
  4. class RUN_PARKING
  5. --
  6. -- Sert de programme principal pour runr le fonctionnement d'un 
  7. -- Parking a trois levelx.
  8. --
  9. creation {ANY}
  10.    make
  11.  
  12. feature {ANY} 
  13.    
  14.    make is
  15.       local
  16.      p: PARKING;
  17.      l1, l2, l3: LEVEL;
  18.      command: COMMAND;
  19.      price: REAL;
  20.      i, value: INTEGER;
  21.       do
  22.      from  
  23.         !!l1.make(14);
  24.         !!l2.make(18);        
  25.         !!l3.make(25);
  26.         !!p.make(<<l1,l2,l3>>);
  27.         !!command.make;
  28.         io.put_string("Simulation du fonctionnement d'un parking.%N%N");
  29.         command.print_help_on(io);
  30.         command.get_command(io);
  31.      until
  32.         command.quit
  33.      loop
  34.         if command.arrival then
  35.            value := p.arrival;
  36.            if value > 0 then
  37.           io.put_integer(value);
  38.           io.put_new_line;
  39.            else
  40.           io.put_string("Error: No More places to Park.%N");
  41.            end;
  42.         elseif command.level_count then
  43.            i := command.arg_integer;
  44.            if  i < p.lower_level then
  45.           io.put_string("Error: Level too small.%N");
  46.            elseif i > p.upper_level then          
  47.           io.put_string("Error: Level too big.%N");
  48.            else
  49.           io.put_integer(p.level_count(i));
  50.           io.put_new_line;
  51.            end;
  52.         elseif command.add_time then
  53.            i := command.arg_integer;
  54.            if i <= 0 then
  55.           io.put_string("Error: Time too small.%N");
  56.            else
  57.           p.add_time(i);
  58.            end;
  59.         elseif command.hour_price then
  60.            price := command.arg_real;
  61.            if price <= 0 then
  62.           io.put_string("Error: It is not Enought.%N");
  63.            else
  64.           p.set_hour_price(price);
  65.            end;
  66.         elseif command.departure then
  67.            i := command.arg_integer;
  68.            if i <= 0 then
  69.           io.put_string("Error: Too Small car #.%N");
  70.            else
  71.           price := p.departure(i);
  72.           if price < 0 then
  73.              io.put_string("Error: this car is already outside.%N");
  74.           else
  75.              io.put_real(price);
  76.              io.put_new_line;
  77.           end;
  78.            end;
  79.         elseif command.clock then
  80.            p.clock.print_on(io);
  81.            io.put_new_line;
  82.         elseif command.count then
  83.            io.put_integer(p.count);
  84.            io.put_new_line;
  85.         elseif command.help then
  86.            command.print_help_on(io);
  87.         else
  88.            io.put_string("Error: Unkown Command.%N");
  89.         end;
  90.         command.get_command(io);
  91.      end;
  92.      io.put_string("Quit%N");
  93.       end;
  94.    
  95. end -- class RUN_PARKING
  96.